package com.mvvm.demo.ui.login

import com.mvvm.demo.entity.UserInfo

data class LoginViewState(
        val isLoading: Boolean,
        val error: String?,
        val userInfo: UserInfo?
) {

    companion object {

        fun initial(): LoginViewState {
            return LoginViewState(
                    isLoading = false,
                    error = null,
                    userInfo = null
            )
        }
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as LoginViewState

        if (isLoading != other.isLoading) return false
        if (error != other.error) return false
        if (userInfo != other.userInfo) return false

        return true
    }

    override fun hashCode(): Int {
        var result = isLoading.hashCode()
        result = 31 * result + (error?.hashCode() ?: 0)
        result = 31 * result + (userInfo?.hashCode() ?: 0)
        return result
    }
}